package com.glsc.ngateway.platform.service.glres;

import com.glsc.ngateway.common.api.common.utils.PageUtil;
import com.glsc.ngateway.platform.domain.*;
import com.glsc.ngateway.platform.repo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author weizt
 * @date 2024/07/11
 * 事件管理流程服务类，
 */
@Service
public class GlscVpnService {

    Logger logger = LoggerFactory.getLogger(GlscVpnService.class);

    @Resource
    private GlscVpnRepository glscVpnRepository;

//    @Resource
//    private DevTaskChangeLogRepository devTaskChangeLogRepository;
//
//    @Resource
//    private DevTaskDetailRepository devTaskDetailRepository;
//
//    @Resource
//    private DevMemberRepository devMemberRepository;
//
//    @Resource
//    private FlowEventUnionImporveRepo flowEventUnionImporveRepo;
//
//    @Resource
//    private GiteeNewService giteeNewService;
//
//    @Resource
//    private AppendixRepo appendixRepo;
//
//    @Resource
//    @Qualifier("transactionManagerMysql")
//    private PlatformTransactionManager transactionManager;
//
//    @Resource
//    private UserCache userCache;
//
//    @Resource
//    private IFeignFlowableService feignFlowableService;
//
//    @Resource
//    private FlowCommonService flowCommonService;
//
//    @Resource
//    private EventImproveService eventImproveService;
//
//    @Resource
//    private ProcessEditConfigService processEditConfigService;
//
//    @Resource
//    private SystemConfigService systemConfigService;
//
//    @Resource
//    private UserService userService;
//
//    @Resource
//    private IFeignLdapService iFeignLdapService;
//
//    @Resource
//    private MailService mailService;
//
//    @Resource
//    private SystemMemberService systemMemberService;
//
//    @Resource
//    private SystemMainService systemMainService;
//
//    @Autowired
//    private DictionaryService dictionaryService;
//
//    @Resource
//    private IFeignShortmsgService iFeignShortmsgService;
//
//    @Resource
//    private TestTaskService testTaskService;
//
//    @Value("${wechat.url}")
//    private String weChatUrl;
//
//    @Resource
//    private VEhrAdminStaffRepository vEhrAdminStaffRepository;

    public Page<Vpn> getProcessSituationPage(Integer pageNo, Integer pageSize, Vpn paramSearchDto, String account) {
//        LocalDateTime start = DateUtils.formatDateToLocalDateTime(DateUtils.formatDateString_(paramSearchDto.getBeginDate()));
//        LocalDateTime end = DateUtils.formatDateToLocalDateTime(DateUtils.formatDateString_(paramSearchDto.getEndDate()));
//        if (end != null) {
//            end = end.plusDays(1);
//        }
//
//        paramSearchDto.setBeginDateLocalDate(start);
//        paramSearchDto.setEndDateLocalDate(end);
//
//        if (StrUtil.isNotEmpty(paramSearchDto.getSystemCode())) {
//            paramSearchDto.setSystemCodes(Arrays.asList(paramSearchDto.getSystemCode().split(",")));
//            paramSearchDto.setSystemCode(null);
//        }

        pageNo = PageUtil.initPageNo(pageNo);
        pageSize = PageUtil.initPageSize(pageSize);
        Pageable pageable = PageRequest.of(pageNo - 1, pageSize);

//        FlowParamAuthDto authCondition = new FlowParamAuthDto();
//        //查询管理有多少人员，以查出人员在改善流程里的事件
//        List<VEhrAdminStaff> staffs = vEhrAdminStaffRepository.findAllByReportTo(account);
//        //分配给任务的人也可以看需求
//        List<FlowFormTaskDetail> formTaskDetails = devTaskDetailRepository.findAllByBeDeletedAndTaskPersonAccount(DictConstant.NO_DELETE,account);
//        List<String> processIds = formTaskDetails.stream().map(e -> e.getProcessId()).collect(Collectors.toList());
//        authCondition.setProcessIds(processIds);
//        Page<FlowFormDevManage> result = null;
//        if (!userService.userRoleContain(Constant.DEV_ADMIN, account)) {
//            authCondition.setAdmin("0");
//        }

        Page<Vpn> result = glscVpnRepository.searchByParam(pageable, paramSearchDto);

//        result = flowEventUnionImporveRepo.searchByParam(pageable,paramSearchDto);
//        List<FlowFormDevManage> content = result.getContent();
//        List<ResponseSituationDevManageDto> process = new ArrayList<>();
//        if (CollectionUtil.isNotEmpty(content)) {
//            for (FlowFormDevManage flow : content) {
//                FlowableResponse<ResponseSituationDto> processInfo = feignFlowableService.getProcessInfo(flow.getProcessId());
//                ResponseSituationDevManageDto dto = new ResponseSituationDevManageDto();
//                BeanUtil.copyProperties(processInfo.getData(), dto);
//                dto.setDemandGrade(flow.getDemandGrade());
//                dto.setSystemCode(flow.getSystemCode());
//                dto.setDemandSummary(flow.getDemandSummary());
//                dto.setDemandClass(flow.getDemandClass());
//                dto.setFlowCreateOperatorName(flow.getFlowCreateOperatorName());
//                dto.setFlowCreateOperatorAccount(flow.getFlowCreateOperatorAccount());
//                dto.setProcessCreateTime(flow.getProcessCreateTime());
//                process.add(dto);
//            }
//        }
//
//        Page<ResponseSituationDevManageDto> resultPage = new PageImpl(process, pageable, result.getTotalElements());
        return result;
    }

}
